#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<vector>
#include<string>
using namespace std;
int numDecodings2(string s) {
    int n = s.size();
    vector<int> dp(n);
    string s1;
    string s2;
    string num_s;
    int i = 0;
    const char* str[26] = { "1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26" };
    while (i < s.size())
    {
        num_s.insert(num_s.size(), str[s[i] - 65]);
        ++i;
    }
    if ('1' <= num_s[0] && num_s[0] <= '9')
        dp[0] = 1;
    if ('1' <= num_s[1] && num_s[1] <= '9')
    {
        dp[1] = 1;
    }
    i = 25;
    while (i)
    {
        if (s1 + num_s[0] + num_s[1] == str[i])dp[1]++; --i;
    }
    cout << dp[0] << ' ' << dp[1]<<endl;
    return 0;
}


int numDecodings(string s) {
    string num_s(s);
    string s1;

    int i = 0;
    const char* str[26] = { "1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26" };
    int n = num_s.size();
    vector<int> dp(n);
    if (n == 1 && '1' <= num_s[0] && num_s[0] <= '9')
    {
        return 1;
    }
    if (n == 2)
    {
        int object = 0;
        if ('1' <= num_s[0] && num_s[0] <= '9')
            ++object;
        i = 25;
        while (i)
        {
            if ((s1 + num_s[0] + num_s[1] == str[i]) && ('1' <= num_s[1] && num_s[1] <= '9'))object++; --i;
        }
        return object;
    }
    if ('1' <= num_s[0] && num_s[0] <= '9')
        dp[0] = 1;
    if ('1' <= num_s[1] && num_s[1] <= '9'&&num_s[0]!='0')
        dp[1] = 1;

    i = 25;
    while (i)
    {
        if (s1 + num_s[0] + num_s[1] == str[i])dp[1]++; --i;
    }

    for (i = 2; i < n; i++)
    {
        int f1 = 0;//dp[i-2]
        int f2 = 0;//dp[i-1]
        if ('1' <= num_s[i] && num_s[i] <= '9')
        {
            f2 = 1;
        }
        int tmp = 25;
        if ('1' <= num_s[i - 1] && num_s[i - 1] <= '9')
        {

            while (tmp)
            {

                if ((s1 + num_s[i - 1] + num_s[i] == str[tmp]))f1 = 1; --tmp;
            }
        }
        if (f1 == 1 && f2 == 1)
            dp[i] = dp[i - 2] + dp[i - 1];
        else if (f1 == 0 && f2 == 1)
            dp[i] = dp[i - 1];
        else if (f1 == 1 && f2 == 0)
            dp[i] = dp[i - 2];
        else
            dp[i] = 0;
    }
    return dp[dp.size() - 1];
}
vector<int> intersection(vector<int>& n1, vector<int>& n2) {
    vector<int>tmp;
    int i = 0; int j = 0; int size = 0;
    for (i = 0; i < n1.size(); i++)
    {
        if (n1[i] == 0)
        {
            continue;
        }
        for (j = 0; j < n2.size(); j++)
        {
            if (n2[i] == 0)
            {
                continue;
            }
            if (n1[i] == n2[j])
            {
                tmp.push_back(n1[i]);
                int a = i; int b = j; int object = n1[i];
                for (; a < n1.size(); a++)
                {
                    if (n1[a] == object)
                    {
                        n1[a] = 0;
                    }
                }
                for (; b < n2.size(); b++)
                {
                    if (n2[b] == object)
                    {
                        n2[b] = 0;
                    }
                }
            }
        }
    }
    return tmp;
}

int main()
{
    //cout<<numDecodings("012")<<endl;//12
    vector<int>v1{ 1,2,3};
    vector<int>v2{ 8,2,2,3,8 };

    intersection(v1, v2);

}
//#include<stack>
//int main() {
//    string s1;
//    cin >> s1;
//    stack<char> a;
//    int i = 0; char tmp = 0;
//    for (i = 0; i < s1.size(); i++)
//    {
//        if (a.empty())
//        {
//            a.push(s1[i]);
//            tmp = s1[i];
//        }
//        else
//        {
//            a.push(s1[i]);
//            if (a.top() == tmp)
//            {
//                a.pop();
//                a.pop();
//                if(!a.empty())
//                tmp = a.top();
//
//            }
//            else {
//                if (!a.empty())
//
//                tmp = a.top();
//            }
//        }
//    }
//    if (a.empty())
//    {
//        cout << 0 << endl;
//    }
//    else
//        string s;
//    while (!a.empty())
//    {
//        s.push_back(a.top());
//        a.pop();
//    }
//}